home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Meeting Pearls 1
/
Meeting Pearls Vol 1 (1994).iso
/
installed_progs
/
dev
/
pattern.library+pgrep
/
pattern.doc
< prev
next >
Wrap
Text File
|
1994-07-04
|
35KB
|
1,074 lines
TABLE OF CONTENTS
pattern.library/--background--
pattern.library/--disclaimer--
pattern.library/--history--
pattern.library/--rexxhost--
pattern.library/--thanx--
pattern.library/AllocPattern
pattern.library/AllocPatternNoCase
pattern.library/Char2Lower
pattern.library/Char2Upper
pattern.library/ESCPattern
pattern.library/GetAllocCounter
pattern.library/FreePattern
pattern.library/IsPattern
pattern.library/MatchThePattern
pattern.library/PatternError2DOS
pattern.library/PatternErrorString
pattern.library/SimpleMatch
pattern.library/SimpleMatchNoCase
pattern.library/Str2Lower
pattern.library/Str2Upper
pattern.library/XMatchPattern
pattern.library/XMatchPatternNoCase
pattern.library/XParsePattern
pattern.library/XParsePatternNoCase
pattern.library/--background-- pattern.library/--background--
PURPOSE
This is a library that helps you in
- pattern matching
- pattern matching with AmigaDOS 2.0 compatible calls (very slow)
- converting strings and characters to uppercase and lowercase
including international characters.
This library knows the following special characters:
- # The following expression or character may be repeated
any number of times, including 0.
- ? Matches any single character.
- | Matches any expression separated by '|'. In AmigaDOS 2.0
the syntax is "(abc|xyz)"; the pattern.library's syntax is
either "(abc|xyz)" or "abc|xyz".
- () With these parentheses it's possible to modify the
evaluation sequence while parsing the string. The
parentheses may be nested.
- % A joker for an empty expression like "".
- ' The following character will not be taken as a special
character, e.g. "'?" is equivalent to the character "?".
These were AmigaDOS 1.3 pattern. Now have a look at the following:
- * Matches any number of characters. Synonymous to "#?" in
AmigaDOS, but shorter.
- ~ Negates the following expression and matches all strings
that do not match exactly to the expression. E.g. ~(abc)
matches to every string that is not exactly "abc",
e.g. "_abc".
No equivalence in AmigaDOS 1.3.
- [] The characters or expressions inside these brackets - e.g.
[a#bc(de)] will be interpreted as (a|#b|c|de). This is much
shorter then the AmigaDOS 1.3 pattern. There may also be a
character-range within the brackets, e.g. [c-h], which
allows any characters from "c" to "h".
If you want the charater "-" to be in the class, put it
directely after "[" or in front of "]".
[~chars] matches any of the characters that are not in
the class.
NOTE: AmigaDOS 2.0 will match "[#?]" to the characters "#"
and "?". pattern.library will match with any string
since "#?" is an expression. If you want to force the
same behaviour as AmigaDOS 2.0, you should type
"['#'?]".
There are matching functions for case-sensitive and case-insensitive
pattern as well. Function-names that contain "NoCase" are
case-insensitive.
EXAMPLES
*1#0 Matches e.g. Amiga1000, Amiga1
~(Amiga500) Matches e.g. Amiga1000, _Amiga500
~(*Amiga500) Matches e.g Amiga1000, not _Amiga500
#[~0-9]1#0 Matches e.g. Amiga1000
Amig?#[~a-zA-Z125-9] Matches e.g. Amiga0003
Amiga'*000 Matches only Amiga*000
#a(#m(#i(#g(#a*)))) Matches e.g. Ammiiigaaaagaagaack
(Amiga|Amig[io])(1000|%) Matches e.g. Amiga, Amigo1000
#A#m#i#g#a|A*a Matches e.g. Angela
FEATURES
1) Matching:
Matches better than AmigaDOS 2.04. For example, AmigaDOS 2.04
thinks that "#(#a#b)" does not match with "aba" and that "#(%|a)"
does not match with "aa". pattern.library is able to perform such
matching operations.
AmigaDOS 2.0 needs parentheses around "|", e.g. (a|bc), which is
not necessary in pattern.library, e.g. a|bc. Of course,
parentheses are allowed!
2) Speed:
pattern.library tries to optimize things for speed. e.g
"#(#<exp1>#<exp2>..)" will be optimized to "#(<exp1>|<exp2>..)"
which means exactly the same but will match faster.
A special built-in pre-match function will pre-check pattern and
string if there's any possibility that the string matches with
the pattern. If not, the result will be returned immediatly.
Pre-check also has a little built-in function that will - in this
library-version - match the following things faster than the
standard matching routine:
"*", "%", "<str>", "[*]<str>[*]...", "<str1>|<str2>...",
"[?]<str>[?]...".
<str> must not contain another pattern. These are patterns that
are used very often.
If a "~" is the first charater of the pattern and if it's
followed by parentheses that include one of the quick-matching
things, matching will also be quick - e.g. ~(*.info)
Perhaps there will be more optimized pattern included in future
versions.
Please note that I can't reach the matching speed of AmigaDOS 2.04
in every case since AmigaDOS 2.04 does not check all possible
alternatives.
Try to stop the time, ARP or AmigaDOS 2.0 needs to match the
pattern "a#?#?#?#?#?#?#?b" with "aaaaaaaaaaaaaaaaaaaaaaaaa"
3) Languages:
This library supports a number of error-strings in different
languages to return an error-message. If you want to be able to
use all supported languages, please copy the file
"Config-Pattern" into your "S:"-directory. Feel free to strip
languages you don't need.
IMPORTANT
Only processes may open and close this library, no tasks. Some
functions must only be called by a process since the function might
use a dos.library-call.
BUGS
- Functions *may* need a lot of stack (in most cases they do not
need much stack), but stack checking is not yet implemented.
TODO
- SearchPattern(): Searches a pattern in a buffer in O(n^2*m)
- MatchFirst(), MatchNext(), MatchEnd()
- More speed while matching: O(n*m)
- Patchtool to patch ARP and Amiga OS 2.0 pattern matching (who
wants to write a patchprogram to patch AmigaDOS 1.3
pattern matching? :-)
pattern.library/--disclaimer-- pattern.library/--disclaimer--
COPYRIGHT
pattern.library, its documentation and all its programmer stuff
and applications are copyrighted (C) 1992 by Angela Schmidt
You must not do anything with this stuff except the things listed
below.
USER
DISTRIBUTOR
This is the disclaimer for all users who want to use any part of
this package.
1) Use
You're allowed to use these things, but there's no guarantee
that everything works correctly. If you use these programs, you
do so at your own risk! If you find unknown bugs, please report
them.
2) Distribution
Feel free to give these things away to your friends if you make
NO PROFIT with it, but remember to spread it in its entirety.
The following files HAVE TO BE included:
pattern.library ... Copy this to LIBS:
pattern.doc ....... User information and programmer-docs
pattern.h ......... Programmer include file
pattern_lib.fd .... Programmer fd-file
Config-Pattern .... This contains the errormessages and
should go to S:
README ............ General information
FILES ............. Info about the files, that are available
The following files MAY be included:
1) pgrep ............. A small grep utility
pgrep.doc.......... Documentation for pgrep
2) PatternTest ....... Test-program with intuition-interface
Also tests arp.library and dos.library
With a German user-interface
PatternTest.info... Icon for PatternTest to start from WB
3) LibMain(NoCase).... Test-programs to start in CLI
LibMain.c ......... C-Source to LibMain(NoCase)
LibMain.Doc ....... short documentation
test/*.tst ........ Test-files for LibMain
e.g. "1> LibMain <test/pt1.tst"
4) pattern.mod ....... Programmer Amiga Oberon Library Module
· NOTHING must be changed/patched in these files!
· All files have to be in the same directory. There must not be
any foreign file in that directory.
· Don't sell any part of this package for profit! You may only
demand the price of an empty disk and a SMALL copy fee.
This excludes also bundling the pattern.library as "freebie"
with any kind of product.
· These things may be only crunched or coded using freely
distributable programs so that everyone can decrunch or decode
it without having to purchase the necessary programs.
· Further ideas to make profit with this are not allowed as well.
· Only non-profit PD-disk series may include pattern.library!
· And here explicitely:
This may be only included on any CD's if you get my permission
to do so. You probably will get it, if nobody will make profit
with the CD. You even MUST NOT include it on Fred Fish CD's
if anybody makes profit with it!!!
This package may be included on the Meeting Pearls CD!
There's one exception to include this package on other disks:
If there's an application that NEEDS the pattern.library, you
may include this package on disks that are not listed above or
that are sold. But note, that in this case you MUST NOT
advertise for any part of this package, since nobody should
get your disk because of the pattern.library and the other
stuff! For more information about using these routines see
below.
I have stated the above conditions, because I learnt the hard way
that there are too many people who make their money with freely
distributable software on disks and CD's and I hate th(is|em).
3) For further use you have to ask me.
PROGRAMMERS
This is the disclaimer for all programmers who want to call these
routines or routines that use these routines (and so on...).
1) Programs that will not be spread
Feel free to implement these routines in your own applications
if you won't spread them.
2) Programs that will be spread
a) Public Domain, Freeware
If you use these routines in applications that will be
spread, and if there's no turnover expected, feel free to
use my routines. If you like, you could send me a copy of
your program as a little acknowledgment for my work with the
pattern.library.
b) Other Software
If your turnover made with the package containing the
pattern.library is less than 10,000 US-Dollar, send me your
released program with its documentation free of charge. If
there are any updates that use the pattern.library, you need
not send more than one update per year.
If you expect a turnover of 10,000 US-Dollars or more (or
anything that has the equivalent value), or if you
unexpectedly reach this limit, you MUST contact me for further
spreading conditions. You MUST NOT use these routines if you
don't contact me. BTW im most cases there won't be a large
change for you when you reach this limit.
For spreading conditions together with your applications see
above.
ADDRESS
My addresses are:
+----------------+------------------------------------------------+
| home address | college (and place of my Amiga 1000) |
+----------------+------------------------------------------------+
| Angela Schmidt | Angela Schmidt |
| Finkenweg 26 | Klosterweg 28/I501 |
| 89233 Neu-Ulm | 76131 Karlsruhe |
| Germany | Germany |
| +49 731/712316 | +49 721/695307 (9am - 10pm MET) |
| (10am-9pm MET) | Angela@rz.uni-karlsruhe.de |
| | Nessy@IRC |
+----------------+------------------------------------------------+
pattern.library/--history-- pattern.library/--history--
VERSION_5
The following functions are available in version 5 of the
pattern.library:
AllocPattern
AllocPatternNoCase
Char2Lower
Char2Upper
ESCPattern
FreePattern
GetAllocCounter
IsPattern
MatchThePattern
PatternError2DOS
PatternErrorString
SimpleMatch
SimpleMatchNoCase
Str2Lower
Str2Upper
Surprise
XMatchPattern
XMatchPatternNoCase
XParsePattern
XParsePatternNoCase
VERSION_5.1
Two bugfixes: · no more enforcerhits while matching "a|b"
· "???..." now is no longer treated as "(???...)".
VERSION_6
Not yet available... :-(
NOTE!!!
Since I've spread some alpha-versions of the pattern.library with
other library-vectors than in this fd-file, remember to open the
pattern.library with the version number 5L (or higher in future
versions):
if (PatternBase=(struct Library *) OpenLibrary (PATLIB_NAME, PATLIB_MIN_VERSION)) {
/* Lib-Calls */
CloseLibrary (PatternBase);
}
Where PATLIB_NAME is #defined to "pattern.library" and
PATLIB_MIN_VERSION is #defined to 5L. (See "pattern.h")
pattern.library/--rexxhost-- pattern.library/--rexxhost--
HOST INTERFACE
pattern.library provides an ARexx function host interface that
enables ARexx programs to take advantage of the wonderful
pattern matching of this library.
The function host library vector is located at offset -30 from the
library. This is the value you provide to ARexx in the AddLib()
function call.
FUNCTION
Str2Upper(STRING/A)
Str2Lower(STRING/A)
PatternMatch(PATTERN/A,STRLIST/A,SEPCHAR,ERRORSTR,LANGUAGE)
PatternMatchNoCase(PATTERN/A,STRLIST/A,SEPCHAR,ERRORSTR,LANGUAGE)
PatternErrorString(ERRNUM/N/A,LANGUAGE)
NOTE: A string must not contain a '\0'-Byte, otherwise it will
be truncated at that position.
Str2Upper
Converts a string to uppercase, including umlauts
Str2Lower
Converts a string to lowercase, including umlauts
PatternMatch
Matches a pattern with the strings in the list. The strings
are separated by the character specified in the 3rd
parameter - if there's any. Otherwise space (0x20) will be
used as a default.
The function returns a list of all strings that matched.
If there occurs an error, the return string will begin with
<ERRORSTR> followed by a number and the errormessage.
If <ERRORSTR> is not specified, it will begin with 0x00.
If <LANGUAGE> is not specified, the default language will be
used to create the errormessage.
NOTE: You can't match strings, that contain a 0x00-Byte,
but you're allowed to use 0x00 as a
separating-character.
PatternMatchNoCase
Same as above but case-insensitive.
PatternErrorString
Returns the errormessage using the specified language. If
there's no language specified, the default language will be
used.
EXAMPLE
/* patternexample.rexx */
/* Make sure pattern.library V5 is loaded as a function host */
IF ~SHOW('L','pattern.library') THEN DO
CALL ADDLIB('pattern.library',0,-30,5)
END
say Str2Upper('FooBar')
say Str2Upper('Test: äöüÄÖÜéèêÉÈÊ')
say Str2Lower('FooBar')
say Str2Lower('Test: äöüÄÖÜéèêÉÈÊ')
say PatternMatch('???','foo foobar bar blubber')
say PatternMatch('???','foo_foobar_bar_blubber','_')
say PatternMatch('#(a#(m#(i#(g#a))))','Aaaamiiiiggga aaamiiigaaa ami angela')
say PatternMatchNoCase('#(a#(m#(i#(g#a))))','Aaaamiiiiggga aaamiiigaaa ami angela')
say PatternMatch('#(ga)#[bnae]','ga-blubb-gaga-hicks-banane-boing-gagabanane','-')
IF ~SHOW('L','rexxsupport.library') THEN DO
CALL ADDLIB('rexxsupport.library',0,-30,0)
END
say PatternMatchNoCase('~(*.info)',ShowDir('SYS:'))
say PatternMatchNoCase('*[a-e][n-t]?[~a-clmnx-z]*',ShowDir('C:'))
say PatternMatchNoCase('*info*|~(*[aiu]*)|??',ShowDir('C:'))
say 'Now you will see an english error message:'
say PatternMatch('[foo','dummy',,'Error: ','english')
pattern.library/--thanx-- pattern.library/--thanx--
THANX
Thanx to all my betatesters for bugreports!
Expecially to:
· Bernhard for writing the test-program PatternTest with its
intuition-interface. For speed-up ideas, memory-managing
routines, stdio routines in pgrep and for the help in building
a shared library.
· Matt Dillon for his NICE DICE :)
· Mr.Scary for translating my Germ-English into something like real
English...
pattern.library/AllocPattern pattern.library/AllocPattern
NAME
AllocPattern -- Compiles a pattern for use with MatchThePattern()
SYNOPSIS
PatternHandle = AllocPattern (pattern, flags)
D0 A0 D0
LONG AllocPattern (STRPTR, ULONG)
FUNCTION
This function compiles a pattern into a special internal format
which is used by MatchThePattern() to test if special strings match
with the pattern or not. This function is case-sensitive.
INPUTS
pattern - pointer to a null-terminated string which contains the
pattern.
flags - for future use only. MUST be set to 0L.
RESULT
PatternHandle - A positive value if everything went right.
A negative value signals a fatal error. Use
the negative value to identify the error.
BUGS
No known bugs
SEE ALSO
FreePattern(), MatchThePattern(), PatternErrorString(),
PatternError2DOS()
pattern.library/AllocPatternNoCase pattern.library/AllocPatternNoCase
NAME
AllocPatternNoCase -- Compiles a pattern for use with
MatchThePattern()
SYNOPSIS
PatternHandle = AllocPatternNoCase (pattern, flags)
D0 A0 D0
LONG AllocPatternNoCase (STRPTR, ULONG)
FUNCTION
This function compiles a pattern into a special internal format
which is used by MatchThePattern() to test if special strings match
with the pattern or not. This function is case-insensitive.
INPUTS
pattern - pointer to a null-terminated string which contains the
pattern.
flags - for future use only. MUST be set to 0L.
RESULT
PatternHandle - A positive value if everything went right.
A negative value signals a fatal error. Use
the negative value to identify the error.
BUGS
No known bugs
SEE ALSO
FreePattern(), MatchThePattern(), PatternErrorString(),
PatternError2DOS()
pattern.library/Char2Lower pattern.library/Char2Lower
NAME
Char2Lower -- Converts a char to lowercase, including umlauts
SYNOPSIS
lowerchar = Char2Lower (anychar)
D0 - 0:8 D0 - 0:8
UBYTE Char2Lower (UBYTE)
FUNCTION
This function converts a given character - including umlauts - to
lowercase. If "anychar" is a non-alphabetical character, the
character is returned, unchanged.
INPUTS
anychar - the character that is to be converted.
RESULT
lowerchar - the converted character.
BUGS
No known bugs
SEE ALSO
Char2Upper(), Str2Lower(), Str2Upper()
pattern.library/Char2Upper pattern.library/Char2Upper
NAME
Char2Upper -- Converts a char to uppercase, including umlauts
SYNOPSIS
upperchar = Char2Upper (anychar)
D0 - 0:8 D0 - 0:8
UBYTE Char2Upper (UBYTE)
FUNCTION
This function converts a given character - including umlauts - to
uppercase. If "anychar" is a non-alphabetical character, the
character is returned, unchanged.
INPUTS
anychar - the character that is to be converted.
RESULT
upperchar - the converted character.
BUGS
No known bugs
SEE ALSO
Char2Lower(), Str2Lower(), Str2Upper()
pattern.library/ESCPattern pattern.library/ESCPattern
NAME
ESCPattern -- Converts a string into a pattern
SYNOPSIS
result = ESCPattern (source, dest, flags)
D0 A0 A1 D0
STRPTR ESCPattern (STRPTR, STRPTR, ULONG)
FUNCTION
This function converts a given string into a pattern. So every
pattern character will be escaped. E.g. the string "50% or more?"
will become "50'% or more'?".
INPUTS
source - A pointer to the string to be converted.
dest - A pointer to a buffer that is at least twice as large as
source plus one byte.
flags - Must be zero for now.
RESULT
result - A pointer to the converted string.
BUGS
No known bugs
SEE ALSO
IsPattern()
pattern.library/FreePattern pattern.library/FreePattern
NAME
FreePattern -- Frees the resources allocated by MatchThePattern()
SYNOPSIS
FreePattern (PatternHandle)
D0
void FreePattern (LONG)
FUNCTION
This function frees all resources allocated by AllocPattern()
or AllocPatternNoCase(). You have to call this when you don't
need the allocated patternhandle any more.
INPUTS
PatternHandle - The longword you received by AllocPattern()
or AllocPatternNoCase().
RESULT
Exec's memory-manager feels happy
BUGS
No known bugs
SEE ALSO
AllocPattern(), AllocPatternNoCase()
pattern.library/GetAllocCounter pattern.library/GetAllocCounter
NAME
GetAllocCounter -- Returns the number of allocated patterns.
SYNOPSIS
counter = GetAllocCounter()
D0
LONG GetAllocCounter()
FUNCTION
This function returns the number of allocated and non-freed patterns.
This is useful while patching pattern matching functions using
SetFunction(). There's a problem while patching matching-functions.
Since every allocated pattern has its own format returned by
pattern.library/AllocPattern, arp.library/PreParse,
dos.library/ParsePattern... you have to make sure that there's
no allocated pattern while patching any matching- or free-function.
Otherwise a library may get a pattern compiled by an other
library. This might cause mysterious things...
You may only patch these allocation-, matching- and free-routines
if GetAllocCounter() returns 0.
NOTE: Even this is not safe if you use GetAllocCounter(). Remember
that any program could be in the library's interface-stuff or at the
very beginning of the matching routine. But it's much better than
patching without checking anything. There's NO way to make patching
these routines totally safe. But let's try to make it as safe as
possible!
This function was NOT written to patch any library vectors of the
pattern.library :-(. It was only written to make unpatching
arp.library, dos.library, ... safer.
INPUTS
No inputs
RESULT
counter - the number of allocated patterns.
BUGS
No known bugs
SEE ALSO
-
pattern.library/IsPattern pattern.library/IsPattern
NAME
IsPattern -- Checks if a given string is a pattern.
SYNOPSIS
result = IsPattern (pattern, topattern, flags)
D0 A0 A1 D0
LONG IsPattern (STRPTR, STRPTR, ULONG)
FUNCTION
This function tests if a given string contains pattern-tokens and
copies the string without quotes into topattern. For example "'?'*"
becomes to "?*". This pattern may be compared with a string faster
using strcmp().
INPUTS
pattern - pointer to a null-terminated string which is to be
examined.
topattern - pointer to a buffer which contains at least as many
bytes as the string pattern. Can be set to 0 if you
don't want the string to be copied.
flags - has to be NULL for now.
RESULT
result - 0 if the pattern contains no pattern characters. So
you can use strcmp (topattern, teststring) to test for a
match.
Otherwise it's a real pattern and you have to call
AllocPattern/NoCase(). Note: Call
AllocPattern/NoCase() with the original pattern!
BUGS
No known bugs
SEE ALSO
AllocPattern(), MatchThePattern()
pattern.library/MatchThePattern pattern.library/MatchThePattern
NAME
MatchThePattern -- Matches a pattern with a string
SYNOPSIS
result = MatchThePattern (ph, string)
D0 D0 A0
LONG MatchThePattern (LONG, STRPTR)
FUNCTION
This function tests if a pattern matches with the given string
or not. This function is case-sensitive.
NOTE: Make sure you don't call this function more than once AT THE
SAME TIME with the same pattern-handle ph (e.g. using
it in another task or process). Parts of the patternhandle
will be changed while matching.
INPUTS
ph - PatternHandle. You get this calling AllocPattern()
string - pointer to a null-terminated string which has to be
tested for a match.
RESULT
result - 1L if the string matches with the pattern.
0L if the string doesn't match.
Any other negative value signals a fatal error.
BUGS
No known bugs
SEE ALSO
AllocPattern()
pattern.library/PatternError2DOS pattern.library/PatternError2DOS
NAME
PatternError2DOS -- converts error-number
SYNOPSIS
doserror = PatternError2DOS (patternerror)
D0 D0
LONG PatternError2DOS (LONG)
FUNCTION
This functions converts an errornumber returned by AllocPattern(),
AllocPatternNoCase(), MatchThePattern(),... to an existing
AmigaDOS 2.0 errornumber.
INPUTS
patternerror - the negative, private errorcode returned by
AllocPattern(), AllocPatternNoCase(),
MatchThePattern(), SimpleMatch() or
SimpleMatchNoCase ()
RESULT
doserror - the non-private dos-errorcode.
BUGS
No known bugs
SEE ALSO
PatternErrorString()
pattern.library/PatternErrorString pattern.library/PatternErrorString
NAME
PatternErrorString -- converts an errornumber to an errorstring
SYNOPSIS
errorstring = PatternErrorString (patternerr, language, buf, buflen)
D0 D0 A0 A1 D1
STRPTR PatternErrorString (LONG, STRPTR, STRPTR, ULONG)
FUNCTION
This function returns a pointer to an error-description. There are
a lot of translations into different languages. Refer to the file
"Config-Pattern".
NOTE: This must be only called by a process!!!
INPUTS
patternerr - the negative, private errorcode returned by
AllocPattern(), AllocPatternNoCase(),
MatchThePattern(), SimpleMatch() or
SimpleMatchNoCase ()
language - Describes which language you want to get back.
If the demanded language is not available, the english
errorstring will be returned.
buf - specifies a buffer to receive the error message
buflen - specifies the length of the buffer, should be at least
50 in this version.
RESULT
errorstring - a pointer to the text that describes the error.
BUGS
No known bugs
SEE ALSO
PatternError2DOS()
pattern.library/SimpleMatch pattern.library/SimpleMatch
NAME
SimpleMatch -- Matches a pattern with one string
SYNOPSIS
result = SimpleMatch (pattern, string)
D0 A0 A1
LONG SimpleMatch (STRPTR, STRPTR)
FUNCTION
This function matches one pattern with one string in a case-sensitive
way. You should only use this function, if you don't want to match
the pattern with more than one string, otherwise you will be very
slow!
INPUTS
pattern - pointer to a null-terminated string which contains the
pattern.
string - pointer to a null-terminated string which has to be
tested for a match.
RESULT
result - 1L if the string matches with the pattern.
0L if the string doesn't match.
Any other negative value signals a fatal error.
BUGS
No known bugs
SEE ALSO
SimpleMatchNoCase(), AllocPattern(), MatchThePattern(), FreePattern()
pattern.library/SimpleMatchNoCase pattern.library/SimpleMatchNoCase
NAME
SimpleMatchNoCase -- Matches a pattern with one string,
case-insensitive
SYNOPSIS
result = SimpleMatchNoCase (pattern, string)
D0 A0 A1
LONG SimpleMatchNoCase (STRPTR, STRPTR)
FUNCTION
This function matches one pattern with one string in a
case-insensitive way. You should only use this function, if you
don't want to match the pattern with more than one string,
otherwise you will be very slow!
INPUTS
pattern - pointer to a null-terminated string which contains the
pattern.
string - pointer to a null-terminated string which has to be
tested for a match.
RESULT
result - 1L if the string matches with the pattern.
0L if the string doesn't match.
Any other negative value signals a fatal error.
BUGS
No known bugs
SEE ALSO
SimpleMatch(), AllocPatternNoCase(), MatchThePattern(),
FreePattern()
pattern.library/Str2Lower pattern.library/Str2Lower
NAME
Str2Lower -- Converts a string to lowercase, including umlauts
SYNOPSIS
lowerstring = Str2Lower (anystring)
D0 A0
STRPTR Str2Lower (STRPTR)
FUNCTION
This function converts a given string - including umlauts - to
lowercase. If any character is a non-alphabetical character,
nothing will change. The result overwrites the input.
INPUTS
anystring - the null-terminated string that is to be converted. This
will be overwritten!
RESULT
lowerstring - pointer to the converted string.
BUGS
No known bugs
SEE ALSO
Char2Lower(), Char2Upper(), Str2Upper()
pattern.library/Str2Upper pattern.library/Str2Upper
NAME
Str2Upper -- Converts a string to uppercase, including umlauts
SYNOPSIS
upperstring = Str2Upper (anystring)
D0 A0
STRPTR Str2Upper (STRPTR)
FUNCTION
This function converts a given string - including umlauts - to
uppercase. If any character is a non-alphabetical character,
nothing will change. The result overwrites the input.
INPUTS
anystring - the null-terminated string that is to be converted. This
will be overwritten!
RESULT
upperstring - pointer to the converted string.
BUGS
No known bugs
SEE ALSO
Char2Lower(), Char2Upper(), Str2Lower()
pattern.library/XMatchPattern pattern.library/XMatchPattern
NAME
XMatchPattern -- Checks for a pattern match with a string
SYNOPSIS
match = XMatchPattern (pat, str)
D0 D1 D2
BOOL XMatchPattern (STRPTR, STRPTR)
FUNCTION
Checks for a pattern match with a string. The pattern must be
the output by XParsePattern(). This routine is case-sensitive.
NOTES: Make sure you've a lot of free stack. There's _no_
built-in-stack-checking in this routine!
This function call is compatible to AmigaDOS 2.0. Please note
that you'd be better off using MatchThePattern() if you don't
_need_ to be compatible with AmigaDOS 2.0 !!!
NOTE: This must be only called by a process!!!
INPUTS
pat - Special pattern string to match as returned by XParsePattern()
str - String to match with given pattern
RESULT
match - success or failure of pattern match. On failure,
IoErr() will return 0 or an error.
SEE ALSO
XParsePattern(), XMatchPatternNoCase()
dos.library/MatchPattern()
pattern.library/XMatchPatternNoCase pattern.library/XMatchPatternNoCase
NAME
XMatchPatternNoCase -- Checks for a pattern match with a string
SYNOPSIS
match = XMatchPatternNoCase (pat, str)
D0 D1 D2
BOOL XMatchPatternNoCase (STRPTR, STRPTR)
FUNCTION
Checks for a pattern match with a string. The pattern must be
the output by XParsePatternNoCase(). This routine is
case-insensitive.
NOTES: Make sure you've a lot of free stack. There's _no_
built-in-stack-checking in this routine!
This function call is compatible to AmigaDOS 2.0. Please note
that you'd be better off using MatchThePattern() if you don't _need_
to be compatible with AmigaDOS 2.0 !!!
NOTE: This must be only called by a process!!!
INPUTS
pat - Special pattern string to match as returned by
XParsePatternNoCase()
str - String to match with given pattern
RESULT
match - success or failure of pattern match. On failure,
IoErr() will return 0 or an error.
SEE ALSO
XParsePattern(), XMatchPattern()
dos.library/MatchPatternNoCase()
pattern.library/XParsePattern pattern.library/XParsePattern
NAME
XParsePattern -- Create a tokenized string for XMatchPattern()
SYNOPSIS
IsWild = XParsePattern (Source, Dest, DestLength)
D0 D1 D2 D3
LONG XParsePattern (STRPTR, STRPTR, LONG)
FUNCTION
Creates the output needed by XMatchPattern(). Also indicates if
there are any wildcards in the pattern.
NOTE: This function call is compatible with AmigaDOS 2.0, but
if there is any possibility to use AllocPattern(), you'd be better
off to use that function!
NOTES: This must be only called by a process!!!
The compiled pattern is NOT compatible to a pattern, that
was compiled using AmigaDOS 2.0 ParsePattern(). So don't
use this output in AmigaDOS 2.0 MatchPattern() and
vice versa.
INPUTS
Source - unparsed wildcard string to search for.
Dest - output string for use with XMatchPattern()
DestLength - length available in destination
RESULT
IsWild - 1 means there were wildcards in the pattern,
0 means there were no wildcards in the pattern,
-1 means there was a buffer overflow or other error
SEE ALSO
XParsePatternNoCase(), XMatchPattern()
dos.library/ParsePattern()
pattern.library/XParsePatternNoCase pattern.library/XParsePatternNoCase
NAME
XParsePatternNoCase -- Create a tokenized string for
XMatchPatternNoCase()
SYNOPSIS
IsWild = XParsePatternNoCase (Source, Dest, DestLength)
D0 D1 D2 D3
LONG XParsePatternNoCase (STRPTR, STRPTR, LONG)
FUNCTION
Creates the output needes by XMatchPatternNoCase(). Also indicates
if there are any wildcards in the pattern.
NOTE: This function call is compatible to AmigaDOS 2.0. But
if there is any possibility to use AllocPattern(), you'd
be better off to use this function!
NOTES: This must be only called by a process!!!
The compiled pattern is NOT compatible to a pattern, that
was compiled using AmigaDOS 2.0 ParsePattern(). So don't
use this output in AmigaDOS 2.0 MatchPattern() and
vice versa.
INPUTS
Source - unparsed wildcard string to search for.
Dest - output string for use with XMatchPatternNoCase()
DestLength - length available in destination
RESULT
IsWild - 1 means there were wildcards in the pattern,
0 means there were no wildcards in the pattern,
-1 means there was a buffer overflow or other error
SEE ALSO
XParsePattern(), XMatchPatternNoCase()
dos.library/ParsePatternNoCase()